package a.f.l.a;

import a.c.d;
import a.c.z;
import a.d.t;
import a.d.w;
import a.d.y;
import a.f.ad;
import a.f.tb;

import java.util.*;

public class n
{
  private static final double a = 1.0E-006D;
  private final d b;
  private final qb c;
  private final boolean d;
  private f[] e;
  private final List f;
  private final Map g = new HashMap();
  mb[] h;
  mb[] i;
  mb[] j;
  private w k;
  private w l;
  public static int m;
  
  n(d paramd, qb paramqb)
  {
    this.c = paramqb;
    this.b = paramd;
    this.d = true;
    this.f = Collections.EMPTY_LIST;
    a.f.o localo = paramqb.a();
    Object localObject;
    int n;
    if ((bool) || (a.b(paramd, localo)))
    {
      localObject = a.c(paramd, localo);
      this.e = new f[localObject.length];
      n = 0;
    }
    while (n < localObject.length)
    {
      this.e[n] = new f(paramd, n, localObject[n]);
      n++;
      if (i3 != 0)
      {
        localObject = new ArrayList();
        y localy = localo.n(paramd);
        int i1 = localy.j() - 1;
        int i2 = 0;
        do
        {
          if (i2 >= i1) {
            break;
          }
          a.d.n localn = localy.a(i2);
          if (i3 != 0) {
            break label219;
          }
          if (a(localn)) {
            ((List)localObject).add(localn);
          }
          i2++;
        } while (i3 == 0);
        this.e = new f[((List)localObject).size()];
        if (!bool) {
          label219:
          i2 = 0;
        }
        do
        {
          if (i2 >= ((List)localObject).size()) {
            break;
          }
          this.e[i2] = new f(paramd, i2, (a.d.n)((List)localObject).get(i2));
          i2++;
        } while (i3 == 0);
      }
    }
  }
  
  void a()
  {
    boolean bool = sb.e;
    int i1 = sb.d;
    HashSet localHashSet = new HashSet();
    int n = 0;
    do
    {
      if (n >= this.e.length) {
        break;
      }
      if (i1 != 0) {
        break label122;
      }
      f localf = this.e[n];
      double d1 = localf.e();
      eb localeb = new eb(d1, d1);
      localf.b(localeb);
      pc localpc = localf.l();
      if (!bool)
      {
        if (localpc != null)
        {
          if (bool) {
            continue;
          }
          if (localHashSet.add(localpc))
          {
            localpc.a(localeb);
            localpc.c().b(localeb);
          }
        }
        n++;
      }
    } while (i1 == 0);
    label122:
    do
    {
      Iterator localIterator = d().iterator();
      while (i1 == 0)
      {
        if (!localIterator.hasNext()) {
          break;
        }
        ((m)localIterator.next()).a(this);
      }
    } while (bool);
  }
  
  private boolean a(a.d.n paramn)
  {
    boolean bool = sb.e;
    if (!bool) {
      if (!paramn.c()) {
        if (bool) {
          break label27;
        }
      }
    }
    label27:
    return paramn.b();
  }
  
  public n(ob paramob, qb paramqb)
  {
    this.c = paramqb;
    this.b = paramob.a();
    this.d = false;
    this.f = a(paramob);
    z localz = a(this.f);
    c(localz);
    a(this.e);
  }
  
  n(d paramd, List paramList, qb paramqb)
  {
    this.c = paramqb;
    this.b = paramd;
    this.d = false;
    this.f = null;
    c(paramList);
  }
  
  public boolean b()
  {
    return this.d;
  }
  
  private void a(f[] paramArrayOff)
  {
    if (paramArrayOff.length > 1)
    {
      o localo = this.c.c().a(this.b);
      f localf1 = paramArrayOff[1];
      t localt1 = this.c.a().v(this.b.e());
      a(localf1, localt1, localo.a());
      f localf2 = paramArrayOff[(paramArrayOff.length - 2)];
      t localt2 = this.c.a().v(this.b.f());
      a(localf2, localt2, localo.b());
    }
  }
  
  private void a(f paramf, t paramt, double paramDouble)
  {
    boolean bool = sb.e;
    eb localeb1 = paramf.g() ? new eb(paramt.d(), paramt.d() + paramt.b()) : new eb(paramt.e(), paramt.e() + paramt.c());
    eb localeb2 = new eb(localeb1.a() - paramDouble, localeb1.b() + paramDouble);
    eb localeb3 = paramf.c();
    if (!bool)
    {
      if (!localeb2.a(localeb3, 1.0E-006D)) {
        return;
      }
      if (bool) {}
    }
    else if (localeb3.a() < localeb1.a() + 1.0E-006D)
    {
      d1 = Math.max(localeb3.a(), localeb2.a());
      paramf.b(new eb(localeb3.a(), d1));
      if (bool) {
        break label186;
      }
      if (sb.d == 0) {
        return;
      }
    }
    double d1 = Math.min(localeb2.b(), localeb3.b());
    label186:
    paramf.b(new eb(d1, localeb3.b()));
  }
  
  private List a(ob paramob)
  {
    boolean bool2 = sb.e;
    int i1 = sb.d;
    if (paramob.e() == 0) {
      return Collections.EMPTY_LIST;
    }
    z localz = new z();
    Object localObject1 = null;
    Object localObject2 = null;
    int n = paramob.e() - 1;
    do
    {
      if (n < 0) {
        break;
      }
      h localh = paramob.a(n);
      mb localmb = localh.a();
      jb localjb = localh.c();
      Object localObject3;
      Object localObject4;
      if (n == 0)
      {
        localObject3 = localObject2;
        localObject4 = new m(this.b, localmb, null, (jb)localObject3, null, localObject1.d(), 0);
        localz.add(0, localObject4);
        this.g.put(localh, localObject4);
        if (bool2) {
          continue;
        }
        if (i1 == 0) {}
      }
      else
      {
        Object localObject5;
        if (localObject1 != null)
        {
          localObject3 = localObject2;
          localObject4 = localh.d();
          tb localtb = localObject1.d();
          if ((localObject4 == localtb) && ((bool2) || (localjb.e((jb)localObject3)))) {
            localjb = jb.a((jb)localObject2, localh.c());
          }
          localObject5 = new m(this.b, localmb, localjb, (jb)localObject3, (tb)localObject4, localtb, 0);
          localz.add(0, localObject5);
          this.g.put(localh, localObject5);
          if (bool2) {
            continue;
          }
          if (i1 == 0) {}
        }
        else
        {
          localObject3 = this.c.a(this.b);
          if ((bool2) || (localObject3 != null))
          {
            localObject4 = ((r)localObject3).a(((r)localObject3).a(paramob, false));
            if ((bool2) || (!((List)localObject4).isEmpty()))
            {
              boolean bool1 = localh.d().e();
              localObject5 = (ad)((List)localObject4).get(0);
              w localw = ((r)localObject3).a((ad)localObject5, false);
              double d1 = bool1 ? localw.a() : localw.b();
              double d2 = localjb.f();
              localjb = new jb(d1, d1, d2, !bool1);
            }
          }
          localObject4 = new m(this.b, localmb, localjb, null, localh.d(), null, 0);
          localz.add(0, localObject4);
          this.g.put(localh, localObject4);
        }
      }
      localObject2 = localjb;
      localObject1 = localh;
      n--;
    } while (i1 == 0);
    return localz;
  }
  
  private z a(List paramList)
  {
    boolean bool = sb.e;
    int i1 = sb.d;
    int n = 0;
    z localz1 = new z();
    Iterator localIterator = paramList.iterator();
    do
    {
      if (!localIterator.hasNext()) {
        break;
      }
      m localm = (m)localIterator.next();
      localm.a(n);
      z localz2 = localm.q();
      if (!bool)
      {
        if (i1 != 0) {
          break label92;
        }
        localz1.addAll(localz2);
        n = localm.g();
      }
    } while (i1 == 0);
    label92:
    return localz1;
  }
  
  private void c(List paramList)
  {
    boolean bool = sb.e;
    int i2 = sb.d;
    f[] arrayOff = new f[((e)paramList.get(paramList.size() - 1)).j() + 1];
    this.h = new mb[arrayOff.length - 1];
    this.i = new mb[arrayOff.length - 1];
    this.j = new mb[arrayOff.length - 1];
    tb localtb = null;
    int n = -1;
    Object localObject1 = null;
    eb localeb1 = null;
    eb localeb2 = null;
    ArrayList localArrayList = new ArrayList();
    Iterator localIterator = paramList.iterator();
    if (localIterator.hasNext()) {}
    Object localObject2;
    Object localObject3;
    Object localObject4;
    label267:
    label270:
    label275:
    label379:
    while (bool)
    {
      localObject2 = (e)localIterator.next();
      if ((!bool) && (i2 != 0)) {
        break label431;
      }
      if (n != ((e)localObject2).j())
      {
        if (!bool)
        {
          if (localObject1 != null)
          {
            localObject3 = ((e)localObject2).h();
            localObject4 = new f(localObject1.i(), n, localObject1.h(), localObject1.c(), localeb1, localeb2, localArrayList);
            localArrayList = new ArrayList();
            arrayOff[n] = localObject4;
            if (!bool) {
              if (localtb != null)
              {
                if (bool) {
                  break label275;
                }
                if (((tb)localObject3).c() == localtb)
                {
                  if ((bool) || ((tb.c == localtb) || (tb.b == localtb)))
                  {
                    if (bool) {
                      break label267;
                    }
                    ((f)localObject4).a((byte)-1);
                    if (i2 == 0) {
                      break label270;
                    }
                  }
                  ((f)localObject4).a((byte)1);
                }
              }
            }
            localtb = localObject1.h();
          }
          localObject1 = localObject2;
          localeb2 = ((e)localObject2).b();
        }
        localeb1 = ((e)localObject2).a();
        n++;
        if (bool) {
          break label379;
        }
        if (i2 == 0) {}
      }
      else
      {
        if (!bool) {}
        if (!bool) {}
        localeb1 = localeb1 == null ? ((e)localObject2).a() : ((e)localObject2).a() == null ? localeb1 : eb.b(localeb1, ((e)localObject2).a());
        localeb2 = eb.b(localeb2, ((e)localObject2).b());
      }
      localArrayList.add(localObject2);
      if (i2 == 0) {
        break;
      }
    }
    if (localObject1 != null) {
      arrayOff[(arrayOff.length - 1)] = new f(localObject1.i(), arrayOff.length - 1, localObject1.h(), localObject1.c(), localeb1, localeb2, localArrayList);
    }
    label431:
    int i1 = 0;
    label561:
    label566:
    label630:
    do
    {
      if (i1 >= arrayOff.length - 1) {
        break;
      }
      localObject2 = arrayOff[i1];
      localObject3 = arrayOff[(i1 + 1)];
      localObject4 = ((f)localObject3).b(0).m();
      this.h[i1] = localObject4;
      if ((!bool) && (i2 != 0)) {
        return;
      }
      e locale;
      if (!bool)
      {
        if (((f)localObject2).m() > 1)
        {
          locale = ((f)localObject2).b(((f)localObject2).m() - 2);
          if (!bool)
          {
            if (locale.g()) {
              this.j[i1] = locale.m();
            }
          }
          else
          {
            if (bool) {
              break label566;
            }
            if (i2 == 0) {
              break label561;
            }
          }
          this.i[i1] = locale.m();
        }
        if (bool) {}
      }
      else
      {
        if (((f)localObject3).m() > 1)
        {
          locale = ((f)localObject3).b(1);
          if (!bool)
          {
            if (locale.g()) {
              this.j[i1] = locale.m();
            }
          }
          else
          {
            if (bool) {
              continue;
            }
            if (i2 == 0) {
              break label630;
            }
          }
          this.i[i1] = locale.m();
        }
        i1++;
      }
    } while (i2 == 0);
    if (!bool) {
      this.e = arrayOff;
    }
  }
  
  public d c()
  {
    return this.b;
  }
  
  public List d()
  {
    return this.f;
  }
  
  public m a(h paramh)
  {
    return (m)this.g.get(paramh);
  }
  
  public f a(int paramInt)
  {
    if (paramInt >= this.e.length) {
      return null;
    }
    return this.e[paramInt];
  }
  
  public f a(f paramf)
  {
    if (!sb.e) {}
    return paramf.j() > 0 ? a(paramf.j() - 1) : null;
  }
  
  public f b(f paramf)
  {
    return a(paramf.j() + 1);
  }
  
  public int e()
  {
    return this.e.length;
  }
  
  public String toString()
  {
    boolean bool = sb.e;
    int i1 = sb.d;
    StringBuffer localStringBuffer = new StringBuffer();
    do
    {
      for (int n = 0; i1 == 0; n++)
      {
        if (n >= this.e.length) {
          break;
        }
        if (i1 != 0) {
          break label62;
        }
        localStringBuffer.append(this.e[n].h().toString());
      }
    } while (bool);
    label62:
    return localStringBuffer.toString();
  }
  
  public w f()
  {
    return this.k;
  }
  
  public void a(w paramw)
  {
    boolean bool = sb.e;
    this.k = paramw;
    f localf = this.e[0];
    localf.a(true);
    if (!bool) {
      if (localf.f())
      {
        if (((bool) || ((!localf.g()) || ((bool) || (Math.abs(localf.e() - paramw.a) <= 1.0E-006D)))) && ((!bool) && ((localf.g()) || (Math.abs(localf.e() - paramw.b) <= 1.0E-006D)))) {
          return;
        }
        throw new IllegalArgumentException("Port location (" + paramw.a() + ", " + paramw.b() + ") contradict the fixed location " + localf.e() + " of the first segment");
      }
    }
    localf.a(localf.g() ? paramw.a : paramw.b);
  }
  
  public w g()
  {
    return this.l;
  }
  
  public void b(w paramw)
  {
    boolean bool = sb.e;
    this.l = paramw;
    f localf = this.e[(e() - 1)];
    localf.a(true);
    if (!bool) {
      if (localf.f())
      {
        if (((bool) || ((!localf.g()) || ((bool) || (Math.abs(localf.e() - paramw.a) <= 1.0E-006D)))) && ((!bool) && ((localf.g()) || (Math.abs(localf.e() - paramw.b) <= 1.0E-006D)))) {
          return;
        }
        throw new IllegalArgumentException("Port location (" + paramw.a() + ", " + paramw.b() + ") contradict the fixed location " + localf.e() + " of the first segment");
      }
    }
    localf.a(localf.g() ? paramw.a : paramw.b);
  }
  
  private w h()
  {
    boolean bool = sb.e;
    if (!bool) {
      if (this.k != null) {
        return this.k;
      }
    }
    t localt = this.c.a().v(this.b.e());
    f localf = this.e[0];
    if (!bool) {
      if (tb.c == localf.h()) {
        return new w(localf.e(), localt.e() + localt.c());
      }
    }
    if (!bool) {
      if (tb.a == localf.h()) {
        return new w(localf.e(), localt.e());
      }
    }
    if (tb.d == localf.h()) {
      return new w(localt.d(), localf.e());
    }
    return new w(localt.d() + localt.b(), localf.e());
  }
  
  private w i()
  {
    boolean bool = sb.e;
    if (!bool) {
      if (this.l != null) {
        return this.l;
      }
    }
    t localt = this.c.a().v(this.b.f());
    f localf = this.e[(this.e.length - 1)];
    if (!bool) {
      if (tb.c == localf.h()) {
        return new w(localf.e(), localt.e());
      }
    }
    if (!bool) {
      if (tb.a == localf.h()) {
        return new w(localf.e(), localt.e() + localt.c());
      }
    }
    if (tb.d == localf.h()) {
      return new w(localt.d() + localt.b(), localf.e());
    }
    return new w(localt.d(), localf.e());
  }
  
  public a.d.n[] j()
  {
    boolean bool = sb.e;
    int i1 = sb.d;
    a.d.n[] arrayOfn = new a.d.n[e()];
    Object localObject = null;
    int n = 0;
    Iterator localIterator = k().iterator();
    if (localIterator.hasNext()) {}
    while (bool)
    {
      w localw = (w)localIterator.next();
      if (!bool) {
        if (localObject != null) {
          arrayOfn[(n++)] = new a.d.n((w)localObject, localw);
        }
      }
      localObject = localw;
      if (i1 == 0) {
        break;
      }
    }
    return arrayOfn;
  }
  
  public z k()
  {
    z localz = new z();
    localz.add(h());
    localz.a(l());
    localz.add(i());
    return localz;
  }
  
  private z l()
  {
    boolean bool = sb.e;
    int i1 = sb.d;
    z localz = new z();
    if (!bool)
    {
      if (this.e.length <= 1) {
        return localz;
      }
      if (bool) {}
    }
    else if (!m())
    {
      throw new RuntimeException("found segments without fixed locations!");
    }
    f localf1 = this.e[0];
    double d1 = localf1.e();
    double d2 = localf1.e();
    int n = 1;
    label132:
    do
    {
      if (n >= this.e.length) {
        break;
      }
      f localf2 = this.e[n];
      if (!bool) {
        if (localf2.g())
        {
          d1 = localf2.e();
          if (bool) {
            continue;
          }
          if (i1 == 0) {
            break label132;
          }
        }
      }
      d2 = localf2.e();
      localz.add(new w(d1, d2));
      n++;
    } while (i1 == 0);
    return localz;
  }
  
  private boolean m()
  {
    int i1 = sb.d;
    int n = 0;
    do
    {
      if (n >= this.e.length) {
        break;
      }
      f localf = this.e[n];
      if (i1 != 0) {
        break label43;
      }
      if (!localf.f()) {
        return false;
      }
      n++;
    } while (i1 == 0);
    label43:
    return true;
  }
  
  void a(f paramf1, f paramf2)
  {
    boolean bool = sb.e;
    int i3 = sb.d;
    if (!bool) {}
    int n = paramf1.j() < paramf2.j() ? 1 : 0;
    if (!bool) {}
    int i1 = n != 0 ? paramf1.j() : paramf2.j();
    f[] arrayOff = new f[this.e.length + 2];
    int i2 = 0;
    do
    {
      if (i2 >= i1) {
        break;
      }
      if (bool) {
        break label131;
      }
      arrayOff[i2] = this.e[i2];
      i2++;
      if (i3 != 0) {
        break label125;
      }
    } while (i3 == 0);
    if (!bool) {
      arrayOff[i1] = (n != 0 ? paramf1 : paramf2);
    }
    label125:
    arrayOff[(i1 + 1)] = (n != 0 ? paramf2 : paramf1);
    label131:
    i2 = i1;
    if (i2 < this.e.length) {}
    while (bool)
    {
      f localf = this.e[i2];
      localf.a(i2 + 2);
      arrayOff[(i2 + 2)] = localf;
      i2++;
      if ((!bool) && (i3 != 0)) {
        return;
      }
      if (i3 == 0) {
        break;
      }
    }
    this.e = arrayOff;
  }
}



/* Location:           E:\idea\

 * Qualified Name:     a.f.l.a.n

 * JD-Core Version:    0.7.0.1

 */